<script type="">

    $(document).ready(function(){                    
        $("#open_pop,#open_pop_2").colorbox({inline:true,width:"450px", height:"200px",opacity:0.1,onLoad: function(){  
                $('#cboxClose').remove();              
            }        
        });                

    });
    
    function edit_mode(id){
        $('#edit_id').val(id);            
        $('#role_name_edit').val($('#role_name_'+id).html());        
        $('#role_description_edit').val($('#role_des_'+id).html());    
    }    

    function update_role(){
        var id = $('#edit_id').val();
        if(id == 0){
            var role_name = $('#role_name').val();       
            var role_description = $('#role_description').val();                           
        }else{
            var role_name = $('#role_name_edit').val();       
            var role_description = $('#role_description_edit').val();                               
        }
        

        if(role_name == ''){
            alert('Bạn chưa nhập tên cho chức vụ!');return false;
        }

        var strUrl = '<?=$url->createUrl("project/ajaxUpdateRole") ?>';            
        loadingAjax();
        $.ajax({
            type: "GET",
            url: strUrl,
            data: {id:id,role_name:role_name,role_description:role_description},
            success: function(msg){                            
                if(msg==1){                       
                    location.reload();   
                }
            }
        });

        closeLoadingAjax();
    }

    function delete_role(role_id){
        if(confirm('Bạn có chắc chắn muốn xóa?')){
            var strUrl = '<?=$url->createUrl("project/ajaxDeleteRole") ?>';            
            loadingAjax();
            $.ajax({
                type: "GET",
                url: strUrl,
                data: {role_id:role_id},
                success: function(msg){                            
                    if(msg==1){                       
                        $('#role_row_'+role_id).hide('slow');
                    }
                }
            });

            closeLoadingAjax();            
        }
    }

</script>